package cn.bdqn.t354.dao;

import cn.bdqn.t354.entity.User;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;
import java.util.List;

@SpringBootTest
@RunWith(SpringRunner.class)
public class UserDaoCrudTester {
    @Resource
    UserDao userDao;

    @Test
    public void testSave(){
        User user=new User("yunxu","123456",1l,1);
        userDao.save(user);
    }

    @Test
    public void testUpdate(){
        User user=new User(24l,"jujue","88888",2l,0);
        userDao.save(user);
    }

    @Test
    public void testDelete(){
       userDao.deleteById(24l);
    }

    @Test
    public void testFindAll(){
        List<User> list = userDao.findAll();
        for (User user : list) {
            System.out.println(user);
        }
    }

    @Test
    public void testFindById(){
        User user = userDao.findById(2l).get();
        System.out.println(user);
    }
}
